package com.itheima.dao;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {
    //查询所有用户信息
    @Select("select * from user")
    List<User> findAll();

    //根据id查询用户信息
    @Select("select * from user where id=#{id}")
    User findById(Integer id);

    //保存用户信息
    @Insert("insert into user values(null,#{username},#{password},#{realname},#{gender},#{birthday}")
    void save(User user);

    //修改用户信息
    @Update("update user set username=#{username},password=#{password},realname=#{realname},gender=#{gender},birthday=#{birthday} where id=#{id}")
    int update(User user);

    //根据id删除用户信息
    @Delete("delete from user where id=#{id}")
    int delete(Integer id);

    //根据用户名和密码查询用户信息
    @Select("select * from user where username=#{username} and password=#{password}")
    User findUserByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
}
